home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / sharewar / webscrip / webscripter4s.exe / {app} / Includes / jsScroll.ob < prev    next >
Encoding:
Text File  |  2001-07-11  |  3.3 KB  |  165 lines

  1. //begin_lib <!-- Begin External JavaScript -- DO NOT REMOVE THIS LINE -->
  2.  
  3. var scSpeed =150; var scTimer = null; var scLimit = 0; var scCount = 0; 
  4. var scMsg=""; var scCounter = 0; var scStrings = new Array(); var scCurr =0;
  5. var scElement = window.status; var scIndex = 0; var rtText="";
  6.  
  7. function jsScroll(){
  8. this.Strings = new Array();
  9. this.Add = sc_Add;
  10. this.NoPad = sc_NoPad;
  11. this.SetElement = sc_SetElement;
  12. this.SetSpeed = sc_setSpeed;
  13. this.SetCounter = sc_setCounter;
  14. this.ScrollLeft = sc_Left;
  15. this.ScrollRight = sc_Right;
  16. this.ScrollType = sc_Type;
  17. this.CountLeft = sc_CountLeft;
  18. this.CountRight = sc_CountRight;
  19. this.CountType = sc_CountType;
  20. this.StopNow = sc_Stop;
  21. }
  22.  
  23. function scSetMsg(nmsg){
  24.           if(!scElement){
  25.           window.status = nmsg;
  26.           }else{
  27.           scElement.value = nmsg;
  28.           }
  29. }
  30.  
  31. function scDoLeft(nmsg){
  32.           if(scCount<nmsg.length){
  33.           nmsg= nmsg.substring(0,nmsg.length/2);
  34.           scCurr++;
  35.           }else{
  36.           scCurr=0;
  37.           nmsg= " ";
  38.           }
  39. scSetMsg(nmsg);
  40. }
  41.  
  42. function get_Array(){
  43. var str = scStrings[scIndex];
  44.           if(scCount==str.length){
  45.                        if(scIndex<scStrings.length-1){
  46.                        scIndex++;
  47.                      }else{
  48.                        scIndex=0;
  49.                      scLimit++;
  50.                      }
  51.         scMsg = scStrings[scIndex];
  52.         scCount=0;             
  53.         }
  54. }
  55.  
  56. function sc_Add(text){
  57. var str = "";
  58.      for (var i = 0; i < text.length; i++){
  59.      str+=" ";
  60.      }
  61. this.Strings.push(str+text);
  62. scStrings = this.Strings;
  63. scMsg = scStrings[0];
  64. scIndex=0;
  65. }
  66.  
  67. function sc_NoPad(text){
  68. this.Strings.push(text);
  69. scStrings = this.Strings;
  70. scMsg = scStrings[0];
  71. scIndex=0;
  72. }
  73.  
  74. function sc_SetElement(element){
  75.           if(element){
  76.           scElement = element;
  77.           }
  78. }
  79.  
  80. function sc_setSpeed(i){
  81.           if(!i){
  82.           scSpeed = 100;
  83.           }else{
  84.           scSpeed = i;
  85.           }
  86. }
  87.  
  88. function sc_setCounter(i){
  89.           if(!i){
  90.           scCounter = null;
  91.           }else{
  92.           scCounter = i;
  93.           }
  94. }
  95.  
  96. function sc_Left(){
  97. get_Array();
  98. scCount++;
  99. scDoLeft(scMsg);
  100. scMsg = scMsg.substring(1,scMsg.length)+scMsg.substring(0,1);
  101. scTimer = setTimeout("sc_Left()",scSpeed);
  102. }
  103.  
  104. function sc_Right(){
  105. get_Array();
  106. rtText=scMsg.substring(scMsg.length-scCount,scMsg.length);
  107. scSetMsg(rtText);
  108. scCount++;
  109. scTimer = setTimeout("sc_Right()",scSpeed);
  110. }
  111.  
  112. function sc_Type(){
  113. get_Array();
  114. scCount++;
  115. rtText=scMsg.substring(0,scCount);
  116. scSetMsg(rtText);
  117. scTimer = setTimeout("sc_Type()",scSpeed);
  118. }
  119.  
  120. function sc_CountLeft(){
  121.           if(scLimit<scCounter){
  122.           get_Array();
  123.           scCount++;
  124.           scDoLeft(scMsg);
  125.           scMsg = scMsg.substring(1,scMsg.length)+scMsg.substring(0,1);
  126.           scTimer = setTimeout("sc_CountLeft()",scSpeed);
  127.           }else{
  128.           scLimit=0;
  129.           clearTimeout(scTimer);
  130.           }
  131. }
  132.  
  133. function sc_CountRight(){
  134.           if(scLimit<scCounter){
  135.         get_Array();
  136.         rtText=scMsg.substring(scMsg.length-scCount,scMsg.length);
  137.         scSetMsg(rtText);
  138.          scCount++;
  139.         scTimer = setTimeout("sc_CountRight()",scSpeed);
  140.          }else{
  141.          scLimit=0;
  142.          clearTimeout(scTimer);
  143.          }
  144. }
  145.  
  146. function sc_CountType(){
  147.           if(scLimit<scCounter){
  148.           get_Array();
  149.           scCount++;
  150.           rtText=scMsg.substring(0,scCount);
  151.           scSetMsg(rtText);
  152.           scTimer = setTimeout("sc_CountType()",scSpeed);
  153.           }else{
  154.           scSetMsg("");
  155.           scLimit=0;
  156.           clearTimeout(scTimer);
  157.           }
  158. }
  159.  
  160. function sc_Stop(){
  161. clearTimeout(scTimer);
  162. }
  163.  
  164. //end_lib <!-- End External JavaScript -- DO NOT REMOVE THIS LINE -->
  165.